package com.dome.mvp.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.dome.mvp.R;
import com.jaeger.library.StatusBarUtil;

import java.util.concurrent.TimeUnit;

import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;

/**
 * Time: 6/2/2021 16:45
 * Author: TAO
 * Description:
 */
public class LauncherActivity extends Activity {

    private Disposable subscribe;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        setTheme(R.style.AppTheme_launcher);
        super.onCreate(savedInstanceState);
        subscribe = Observable.timer(1, TimeUnit.SECONDS)
                .subscribe(aLong -> {
                    Intent intent = new Intent(this, MainActivity.class);
                    startActivity(intent);
                    finish();
                    subscribe.dispose();
                });

    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        // 禁用返回键
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }


    @Override
    protected void onDestroy() {
        if (subscribe != null) {
            subscribe.dispose();
            subscribe = null;
        }
        super.onDestroy();
    }
}
